package LayoutFram;

import javax.swing.*;
import java.awt.*;

class Layout extends JFrame {
    public Layout(){

        //设置容器的布局为边框布局
        this.setLayout(new BorderLayout());
        JButton button = new JButton("东邪");
        this.add(button,BorderLayout.EAST);
        JButton button1 = new JButton("西毒");
        this.add(button1,BorderLayout.WEST);
        JButton button2 = new JButton("美女");
        this.add(button2,BorderLayout.SOUTH);
        JButton button3 = new JButton("帅哥");
        this.add(button3,BorderLayout.NORTH);
        JButton button4 = new JButton("中神通");
        this.add(button4,BorderLayout.CENTER);

        //流式布局
//        this.setLayout(new FlowLayout());
//        this.add(new JButton("1"));
//        this.add(new JButton("2"));

        //网格布局
//        this.setLayout(new GridLayout(3,2));
//        this.add(new JButton("1"));
//        this.add(new JButton("2"));
//        this.add(new JButton("3"));
//        this.add(new JButton("4"));
//        this.add(new JButton("5"));
//        this.add(new JButton("6"));

        this.setSize(600,600);
        this.setVisible(true);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
    }


    public static void main(String[] args) {
        new Layout();
    }
}
